﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

namespace eGrocery.Web.Masters
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetCityList();
                FillStates();
                
            }
        }

        private void GetCityList()
        {
            grdCity.DataSource = new Location.CityBL().GetObjectList("", new DateTime(), new DateTime());
            grdCity.DataBind();
        }
         private void FillStates()
        {
            ddlStateName.DataSource = new Location.StateBL().GetObjectList("", new DateTime(), new DateTime());
            ddlStateName.DataTextField = "Full_Name";
            ddlStateName.DataValueField = "ID";
            ddlStateName.DataBind();
            ddlStateName.Items.Insert(0, "Select State");
        }
        protected void btnSave_Click(object sender, EventArgs e)
         {
            var city = new BaseDAL.Model.City();
           // city.ID = 1;
            city.FULL_NAME = txtCityName.Text;
            city.DISPLAY_NAME = txtCityDisplayName.Text;
            city.STATE_ID = Int32.Parse(ddlStateName.SelectedItem.Value);
            city.CREATED_BY = 1;
            city.CREATION_DATE = DateTime.Now;
            city.MODIFIED_BY = 1;
            city.MODIFICATION_DATE = DateTime.Now;
            city.ISLIVE = true;
            city = new Location.CityBL().SaveObject("", city);
            WebHelper.RefreshAllControls(this.Form.FindControl("ContentPlaceHolder1"));
 
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {

        }
      

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            WebHelper.RefreshAllControls(this.Form.FindControl("ContentPlaceHolder1"));
        }

    }
}